Get Collection
Retrieve all documents from a specified collection to access and manage your unstructured data through the Hyperspell MCP server.
Instructions
Get a list of all documents in a collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_name | Yes |
Implementation Reference
- src/hyperspell_mcp/server.py:107-110 (handler)The handler function that executes the logic for the 'Get Collection' tool. It lists all documents in the specified collection using the Hyperspell API and converts them to Document objects.def get_documents(collection_name: str) -> list[Document]: """Get a list of all documents in a collection""" r = mcp.api.documents.list(collection=collection_name) return Document.from_pydantic(r.items)
- src/hyperspell_mcp/types.py:38-43 (schema)Pydantic-compatible dataclass defining the schema for Document objects returned by the 'Get Collection' tool.class Document(BaseModel): id: int title: str type: str summary: str
- src/hyperspell_mcp/server.py:106-106 (registration)Decorator that registers the get_documents handler as the 'Get Collection' tool (or resource) in the MCP server, based on configuration.@mcp.tool_or_resource("collection://{collection_name}", name="Get Collection")
- src/hyperspell_mcp/types.py:7-29 (helper)Helper method used by Document.from_pydantic to convert API response models to the local dataclass format.@dataclass class BaseModel: @overload @classmethod def from_pydantic(cls, model: PydanticBaseModel) -> Self: ... @overload @classmethod def from_pydantic(cls, model: Sequence[PydanticBaseModel]) -> list[Self]: ... @classmethod def from_pydantic( cls, model: PydanticBaseModel | Sequence[PydanticBaseModel] ) -> Self | list[Self]: """Convert a Pydantic model to a data class, selecting only the keys that are part of the data class.""" if isinstance(model, Sequence): return [cls.from_pydantic(m) for m in model] data = model.model_dump() # Only select the keys in data that are part of this data class data = {key: value for key, value in data.items() if key in cls.__annotations__} return cls(**data)